package com.xsg.printer.core.model;

import com.xsg.printer.core.exception.VoucherPrintException;
import lombok.Data;

import java.util.Collection;

@Data
public class XsgElementSheet extends XsgElement{

    private XsgSheet sheet;

    private Collection<Collection<?>> value;

    private XsgFont font;

    @Override
    public void setValue(Object value) {
        if (value instanceof Collection) {
            Collection collection = (Collection)value;
            if (collection == null || collection.isEmpty()) {
                return;
            }
            if (collection.iterator().next() instanceof Collection) {
                this.value = (Collection<Collection<?>>)value;
            } else {
                throw new VoucherPrintException("表格暂不支持该数据类型");
            }
        } else {
            throw new VoucherPrintException("表格暂不支持该数据类型");
        }
    }
}
